;; Enable/disable various third party features (useful when
;; experimenting with new features). Assign 't' to a variable to
;; enable a feature and 'nil' to disable.
(defvar *filladapt-enabled* t)  ;; enhances Emacs’ fill functions
(defvar *flyspell-enabled* t)   ;; enables on-the-fly spell checking
(defvar *header2-enabled* t)    ;; allow customized headers
(defvar *lineker-enabled* nil)  ;; controls allowable line width
(defvar *actionscript-enabled* t)  ;; an actionscript mode
(defvar *ispell-enabled* t)     ;; spell checker
(defvar *opengl-enabled* t)     ;; opengl mode
(defvar *color-enabled* t)      ;; Emacs themes
(defvar *graphviz-enabled* t)   ;; a graphviz mode
(defvar *lilypond-enabled* t)   ;; a lilypond mode
(defvar *gnuplot-enabled* t)    ;; a gnuplot mode
(defvar *haskell-enabled* t)    ;; a haskell mode
(defvar *wordcount-enabled* nil)  ;; a wordcount mode
(defvar *php-mode-enabled* t)   ;; php-mode
(defvar *company-enabled* t)    ;; company-mode
(defvar *javascript-mode* t)    ;; javascript-mode
(defvar *cedet-enabled* nil)      ;; cedet-mode

(when *filladapt-enabled*
  (autoload 'filladapt-mode "filladapt" "Filladapt mode." t))

(when *flyspell-enabled*
  (autoload 'flyspell-mode "flyspell" "Flyspell mode." t))

(when *header2-enabled*
  (autoload 'auto-update-file-header "header2" "Update file header." t)
  (autoload 'make-header "header2"
    "Insert (mode-dependent) header comment at beginning of file." t)
  (defun def-header ()  ;; set default date-format and make-header-hook
    (setq header-date-format nil
	  make-header-hook '(
			     header-title
			     header-blank
			     header-author
			     header-modification-date
			     header-blank
			     header-description
			     )))
  (def-header)
  (add-hook 'write-file-hooks 'auto-update-file-header))

(when *lineker-enabled*
  (autoload 'lineker "lineker" "Lineker." t))

(when *actionscript-enabled*
  (autoload 'actionscript-mode "actionscript-mode" "Actionscript Mode" t))

(when *ispell-enabled*
  (eval-after-load "ispell"
    '(progn
       ;; Use the -C option when running aspell, which will
       ;; ConsiderCamelCaseToBeCorrect
       (setq ispell-extra-args '("-C")))))

(when *opengl-enabled*
  (autoload 'OpenGL-minor-mode "opengl minor mode" "OpenGL editing utilities." t))

(when *color-enabled*
  (autoload 'color-theme "color theme" "Color Theme." t)
  (setq color-theme-is-global t)
  (load-library default-theme)
  (funcall (intern default-theme)))

(when *graphviz-enabled*
  (autoload 'graphviz-dot-mode "graphviz-dot mode" "Graphviz-dot Mode" t))

(when *lilypond-enabled*
  (autoload 'LilyPond-mode "lilypond-mode" "LilyPond Editing Mode" t)
  (add-hook 'LilyPond-mode-hook (lambda () (turn-on-font-lock))))

(when *gnuplot-enabled*
  (autoload 'gnuplot-mode "gnuplot" "Gnuplot Major Mode" t)
  (autoload 'gnuplot-make-buffer "gnuplot" "Open a buffer in gnuplot-mode" t))

(when *haskell-enabled*
  (load-library "haskell-site-file")
  (add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
  (add-hook 'haskell-mode-hook 'turn-on-haskell-indentation))

(when *wordcount-enabled*
  (autoload 'word-count-mode "word-count" "Minor mode to count words." t nil))

(when *php-mode-enabled*
  (autoload 'php-mode "php-mode" "Major mode for editing php code." t))

(when *company-enabled*
(autoload 'company-mode "company" nil t))

(when *javascript-mode*
(autoload 'javascript-mode "javascript" nil t))

(when *cedet-enabled*
(load-file "~/.emacs.d/cedet/common/cedet.el"))
